/*OWmq6Ugo6jPE4W7xoi1UXr4Tp1/n/Vi+P1J4TZWCBleFqRbMKl/Fh/GX//kGX13Z*/
import constants from '../../constants';
import ampub from 'ampub';
import fa from 'fa';

const { fa_components: { ReferLinkage: { referLinkageClear }, AccbookAndPeriod: { getAccbookAndPeriod } } } = fa;
const { ReferLinkageClearConfig, AREA: { LIST: { SEARCH_AREA: searchId } } } = constants;

// 参照过滤业务单元
const { components: { assetOrgMultiRefFilter: { isMultiCorpRefHandler, renderCompleteEvent } } } = ampub;

export default function afterEvent(field, value) {
	//联动处理
	referLinkageClear(this.props, field, ReferLinkageClearConfig);

	if (field === 'pk_org' && value && value.length === 1) {
		//获取账簿
		getAccbookAndPeriod(this.props, searchId);
	}

	// 主组织编辑后：主组织关联参照字段控制其业务单元是否显示
	if (field === 'pk_org') {
		renderCompleteEvent.call(this, this.props, searchId, 'pk_org', orgAfterEvent.bind(this));
	}
}

/**
 * 主组织关联参照字段控制其业务单元是否显示
 * @param {*s} field 
 * @param {*} value 
 */
export function orgAfterEvent(field, value) {
	if (field === 'pk_org') {
		//获取账簿
		isMultiCorpRefHandler.call(this, this.props, value, searchId, [
			// 供应商
			'provider',
			// 项目档案
			'pk_jobmngfil'
		]);
	}
}

/*OWmq6Ugo6jPE4W7xoi1UXr4Tp1/n/Vi+P1J4TZWCBleFqRbMKl/Fh/GX//kGX13Z*/